@import '../mixins';

.autocompletion-container {
  position: relative;
  display: flex;
  flex-direction: column;
}

.CodeMirror-hints {
  list-style: none;
  flex-direction: column;
  padding: 0;
  max-height: 100px;

  // hack to position the dialog a little better than the
  // default codemirror position.
  transform: translate(0, -15px);
  overflow-y: auto;

  li {
    flex-shrink: 0;
    height: 29px;
    padding: 0 var(--spacing);
  }

  // We can't replicate the nice scrollbars that we have in
  // the regular autocomplete popup since that's based on List
  // and this CodeMirror stuff is just an unordered list.
  // The autocomplete popup is not intended to be used with
  // a pointer-device anyway so not being able to mouse-wheel
  // through it shouldn't be a big deal
  @include win32 {
    overflow-y: hidden;
  }
}

.autocompletion-popup {
  overflow: hidden; // To get those sweet rounded corners
}

.autocompletion-popup,
.CodeMirror-hints {
  display: flex;
  position: absolute;
  z-index: var(--popup-z-index);
  width: 250px;

  border-radius: var(--border-radius);

  &.emoji {
    width: 200px;
  }
  &.user {
    width: 220px;
  }
  &.issue {
    width: 300px;
  }

  background-color: var(--background-color);

  box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);

  .list-item,
  li {
    border-bottom: none;

    &:not(:first-child) {
      border-top: var(--base-border);
    }

    &.selected,
    &.CodeMirror-hint-active {
      --text-color: var(--box-selected-active-text-color);
      --text-secondary-color: var(--box-selected-active-text-color);

      color: var(--text-color);
      background-color: var(--box-selected-active-background-color);
      border-top-color: var(--box-selected-active-background-color);

      & + .list-item,
      & + .CodeMirror-hint-active {
        border-top-color: var(--box-selected-active-background-color);
      }
    }
  }
}

.autocompletion-item {
  flex-grow: 1;
  height: 100%;
  min-width: 0;
  padding: 0 var(--spacing);

  /* Used to highlight substring matches in autocompletion texts */
  mark {
    font-weight: bold;
    /* Reset browser defaults */
    background-color: inherit;
    color: currentColor;
  }

  .emoji {
    display: flex;
    flex-grow: 1;

    height: 100%;
    width: 100%;
    align-items: center;

    .icon {
      flex-shrink: 0;
      height: 20px;
      width: 20px;
      margin-right: var(--spacing-half);
    }

    .title {
      @include ellipsis;
      max-width: 100%;
    }
  }

  .issue {
    display: flex;
    flex-grow: 1;
    align-items: center;

    height: 100%;
    width: 100%;

    .number {
      margin-right: var(--spacing-half);
    }

    .title {
      @include ellipsis;
      font-weight: var(--font-weight-semibold);
    }
  }

  .user {
    display: flex;
    flex-grow: 1;
    align-items: center;

    height: 100%;
    width: 100%;

    &.unknown {
      .username {
        font-style: italic;
      }

      .description {
        @include ellipsis;
        color: var(--text-secondary-color);
        font-style: italic;
        font-size: var(--font-size-sm);
      }
    }

    .username {
      @include ellipsis;
      font-weight: var(--font-weight-semibold);
      margin-right: var(--spacing-half);
    }

    .name {
      @include ellipsis;
      color: var(--text-secondary-color);
    }
  }
}

.author-input-component {
  ul.CodeMirror-hints {
    margin-top: var(--spacing-double);
    padding: 0;
    li {
      margin-bottom: auto;
      padding-left: var(--spacing);
    }
  }
}
